﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.VisualStudio.VCProjectEngine;
using EnvDTE;

namespace iMainAddin
{
    public abstract class iVcProject
    {
        protected static DTE m_Application;
        public static DTE Application
        {
            get { return iVcProject.m_Application; }
        }		
        private VCProject m_vcProjcet = null;
        public VCProject VCProjcet
        {
            get { return m_vcProjcet; }
        }
        protected String m_AddintDataPath;
        public System.String AddintDataPath
        {
            get { return m_AddintDataPath; }
        }

        public abstract bool Init();
        public virtual bool Create(Object createValue)
        {
            Solution CurrentSolution = (Solution)Application.Solution;
            m_AddintDataPath = Path.GetDirectoryName(CurrentSolution.FullName) + @"\AddinFile\";
            return true;
        }
        public static bool Startup(DTE application)
        {
            m_Application = application;
            return true;
        }

        protected VCProject SetVCProject(ref SelectedItem selectItem)
        {
            if( selectItem.Project != null )
            {
                m_vcProjcet = selectItem.Project.Object as VCProject;
                return m_vcProjcet;
            }
            else
            {
                if (selectItem.ProjectItem != null && 
                    selectItem.ProjectItem.ContainingProject != null)
                {
                    m_vcProjcet = selectItem.ProjectItem.ContainingProject.Object as VCProject;
                    return m_vcProjcet;
                }
            }
            return null;
        }

        protected VCProject SetVCProject(System.Object newProject)
        {
            m_vcProjcet = newProject as VCProject;
            return m_vcProjcet;
        }
    }
}